package com.haier.npt.logs;

import java.util.ArrayList;

import org.apache.commons.lang.StringUtils;

public class LogUtils {
	public static String format(String[][] methodParameters, String msg) {
		return format(null, methodParameters, msg);
	}

	public static String format(String operationName, String[][] methodParameters, String msg) {
		StringBuilder result = new StringBuilder();
		if (operationName != null) {
			result.append(operationName + "; ");
		}
		result.append(msg + ";");
		String[][] pas = methodParameters;
		if (pas != null && pas.length > 0) {
			ArrayList<String> parList = new ArrayList<>();
			for (int i = 0; i < pas.length; i++) {
				parList.add(pas[i][0] + " : " + pas[i][1]);
			}
			result.append(" 参数: { " + StringUtils.join(parList, " , ") + " }");
		}
		return result.toString();
	}
}
